/**
 * 
 */
package com.changil.nowonchangilchurch.page.news;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.changil.nowonchangilchurch.R;
import com.changil.nowonchangilchurch.common.Constants;
import com.changil.nowonchangilchurch.page.ArticleListFragment;
import com.changil.nowonchangilchurch.page.BaseActivity;
import com.changil.nowonchangilchurch.page.BaseNetworkFragment;

/**
 * @author zeropol2
 *
 */
public class NewsActivity extends BaseActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	protected void initLayout() {
		mHeader.setHeaderText(getString(R.string.church_news));
		mHeader.setHeaderColor(R.color.color_news_n);
		mTabs.setIndicatorColorResource(R.color.color_news_n);
	}

	protected void defineAdapter() {
		mAdapter = new NewsPagerAdapter(getSupportFragmentManager());
	}
	
	private class NewsPagerAdapter extends FragmentPagerAdapter {
		private final String[] TITLES = { getString(R.string.church_news),
				getString(R.string.member_news),
				getString(R.string.church_picture)};

		public NewsPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return TITLES[position];
		}

		@Override
		public int getCount() {
			return TITLES.length;
		}

		@Override
		public Fragment getItem(int position) {
			Fragment nextFragment = null;
			if(0 == position) {
				nextFragment = ArticleListFragment.newInstance(Constants.BOARD_ID_CHURCH_NEWS);
				((BaseNetworkFragment)nextFragment).setForceDataLoad(true);
			} else if( 1 == position) {
				nextFragment = ArticleListFragment.newInstance(Constants.BOARD_ID_MEMBER_NEWS);
			} else if( 2 == position) {
				nextFragment = ArticleListFragment.newInstance(Constants.BOARD_ID_CHURCH_PICTURE);
			} 
			return nextFragment;
		}

	}
}
